package com.hichina.client.util;

import com.hichina.exception.HiChinaException;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * User: zigang.wang
 * Date: 12-4-9
 * Time: 下午1:49
 */
public class ResponseUtils {
    public static JSONObject checkResponse(String jsonContent) throws  HiChinaException {
        try {
            JSONObject json = new JSONObject(jsonContent);
            JSONObject respStatus = json.getJSONObject("respStatus");
            if(respStatus.getInt("statusCode")!= 100){
                throw new HiChinaException(respStatus.toString());
            }
            return json;
        } catch (JSONException e) {
            throw new HiChinaException(jsonContent + " can't convert to json");
        }
    }
}
